
import 'package:flutter/material.dart';
import 'package:freemusic/utils/Util.dart';
import 'package:package_info/package_info.dart';

class AboutPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return AboutPageState();
  }
}

class AboutPageState extends State<AboutPage> {
  PackageInfo _packageInfo;

  @override
  void initState() {
    super.initState();
    PackageInfo.fromPlatform().then((packageInfo) {
      setState(() {
        _packageInfo = packageInfo;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    Color themeColor = Util.themeColor;
    Color wordColor = Util.wordColor;
    TextStyle descritionStyle = TextStyle(color: wordColor, fontSize: 16);
    TextStyle linkStyle = TextStyle(fontSize: 16);
    EdgeInsetsGeometry padding = EdgeInsets.all(12.0);
    return Scaffold(
      appBar: AppBar(
        title: Text("关于"),
        centerTitle: true,
        backgroundColor: themeColor,
        elevation: 1,
      ),
      body: Container(
        padding: EdgeInsets.all(8.0),
        child: Column(
          children: <Widget>[
            Card(
              child: Container(
                padding: padding,
                child: Row(
                  children: <Widget>[
                    Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        Text(
                          "FreeMusic",
                          style: TextStyle(
                              fontSize: 24, fontWeight: FontWeight.bold),
                        ),
                        Text(
                          "Version ${_packageInfo == null ? '' : _packageInfo.version}",
                          style: TextStyle(color: wordColor),
                        ),
                      ],
                    ),
                  ],
                ),
              ),
            ),
            Card(
              child: Container(
                padding: padding,
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Text(
                      "FreeMusic集各大音乐平台于一身，歌曲即听即搜、方便快捷！",
                      style: descritionStyle,
                    ),
                    Text(
                      "本APP不提供任何API，所用网络数据均来自QQ、酷狗、网易云、咪咕等主流音乐平台。",
                      style: descritionStyle,
                    ),
                    Text(
                      "本APP仅供学习使用，不会索取任何费用，禁止倒卖，否则后果自负！",
                      style: descritionStyle,
                    ),
                    Text(
                      "本APP不会搜集任何用户信息，请放心使用！",
                      style: descritionStyle,
                    )
                  ],
                ),
              ),
            ),
            Card(
              child: Container(
                padding: padding,
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  children: <Widget>[
                    Text(
                      "本APP基于 Flutter 构建，使用 Dart 语言编写，插件来源于 Flutter Pub 的国内镜像。插件包含：flutter_flux、dio、marquee、shared_preferences、crypto、sqflite、fluttertoast、audioplayers等等。",
                      style: descritionStyle,
                    )
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
